package com.mahees.portfolio.controller

import com.mahees.portfolio.domain.DBFile;

class RetrieveFileController {

    def show = {
		if (!params.id) {
			redirect(absolute: true, url :'hello');
		}
		
		DBFile dbfile = DBFile.findByName(params.id)
		
		if (dbfile) {
			withFormat {
				image {
					response.outputStream << dbfile.decodeBase64()
					response.outputStream.flush();
				}
			}
		} 
		else {
			redirect(absolute: true, url :'hello');
		}
		
	}
}
